<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('运营服务费申请')"/>
    <th:block th:include="include :: businessCSS"/>
</head>
<body class="no-skin">
<div class="main-container" id="main-container">
    <div class="main-content">
        <form class="layui-form head-form">
            <div class="north">
                <th:block th:include="include :: business_btn"/>
                <th:block th:include="include :: business_tpl('top')"/>
            </div>
            <div class="mid-content">
                <table class="layui-hide" id="dhtable" lay-filter="ftable"></table>
            </div>
            <th:block th:include="include :: pageFooter"/>
        </form>
    </div>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: businessJS"/>
<th:block th:include="include :: businessTableBtn"/>
<th:block th:include="include :: inlineJS"/>
<script type="text/javascript">
    var $, layer, form, table, laydate, element;//定义layui模块
    eachFields();//明细表格中的字段遍历
    layui.use(['laydate', 'table', 'form', 'layer', 'jquery', 'util', 'element'], function () {
        $ = layui.$, layer = layui.layer, form = layui.form, table = layui.table, laydate = layui.laydate, util = layui.util, element = layui.element;
        beforeInit();//表单初始化之前的动作集合
        layui.element.render();
        $.get("/finance/operateservicechargeapply/listbynid?nid=" + nid, function (data) {
            $.each(data.data, function (k, v) {
                dataStr.push(v);
            });
            initTable();//初始化表格
        });
        toolbarEvent();//通用表格头部工具栏事件监听
        toolEvent('ftable');//行event事件监听
        monitorSort();//监听排序——重载赋值渲染
        moneyCalculation();//表格编辑——资金计算

        // 按照选择的费用类型-----交易类型锁定   04-28
        // 运营服务费（支出）-------运营服务→运营服务费
        // 运营预付款（收入）-------运营服务→预付款
        // 预付款退回（支出）--------运营成本→预付款退回
        form.on('select(select_top)', function (data) {//下拉框监听
            console.log("下拉框监听", data.value)
            var ndata = table.cache.dhtable

            if (data.value === '运营服务费（支出）') {
                if (ndata.length > 0) {
                    ndata.forEach(item => {
                        item.vJyLx = '运营服务→运营服务费'
                    });
                }
            } else if (data.value === '运营预付款（收入）') {
                if (ndata.length > 0) {
                    ndata.forEach(item => {
                        item.vJyLx = '运营服务→预付款'
                    });
                }
            } else if (data.value === '预付款退回（支出）') {
                if (ndata.length > 0) {
                    ndata.forEach(item => {
                        item.vJyLx = '运营服务→预付款退回'
                    });
                }
            }
            table.reload('dhtable', {data: ndata});
        })

    })
</script>
</body>
</html>